package com.abou.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * The controller for the exception page
 * 
 * @author ztrt8431
 */
@Controller
public class ExceptionController {
  
  /**
   * The view name of the exception page
   */
  public static final String VIEW_NAME = "exception";
  
  /**
   * The name of the attribute used to store an exception for the exception page
   */
  public static final String EX_CODE_ATT = "excode";
  
  /**
   * The name of the attribute used to store parameters for an exception message
   * for the exception page
   */
  public static final String EX_PARAMS_ATT = "exparams";
  
  /**
   * Shows the exception page
   * 
   * @param back The path to the page where to go back
   * @param model The model
   */
  @RequestMapping("/exception.do")
  public void exception(@RequestParam String back, ModelMap model) {

    model.put(ControllerUtils.OVERRIDE_MAIN_MENUITEM_NAME,
        ControllerUtils.getMainMenuItemIndex(back));
  }
}
